import { createRouter, createWebHashHistory } from 'vue-router'

import Layout from '@/views/Layout'

const routes = [
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  {
    path: '/',
    component: Layout,
    children: [
      { path: '', component: () => import('@/views/Home') },
      {
        path: '/category/:id',
        component: () => import('@/views/Category')
      },
      {
        path: '/category/sub/:id',
        component: () => import('@/views/Category/Sub')
      },
      {
        path: '/goods/:id',
        component: () => import('@/views/Goods')
      },
      {
        path: '/goods/:id',
        component: () => import('@/views/Goods')
      },
      {
        path: '/cart',
        component: () => import('@/views/Cart')
      },
      {
        path: '/Settlement',
        component: () => import('@/views/Settlement')
      },
      {
        path: '/pay',
        component: () => import('@/views/pay')
      },
      { path: '/member', component: () => import('@/views/Member/layout') }
    ]
  },
  {
    path: '/playground',
    component: () => import('@/views/Playground')
  },
  {
    path: '/login',
    component: () => import('@/views/login')
  },
  {
    path: '/login/callback',
    component: () => import('@/views/login/callback')
  },
  {
    path: '/pay/callback',
    component: () => import('@/views/pay/callback.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior: () => ({ x: 0, y: 0 })
})

export default router
